package cn.stronglink.assetmanage.business.inspection.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import cn.stronglink.assetmanage.business.inspection.view.already.AlreadyRepairFragment;
import cn.stronglink.assetmanage.business.inspection.view.repair.RepairFragment;
import cn.stronglink.assetmanage.business.inspection.view.wait.WaitPatrolFragment;

/**
 * 适配器
 * Created by zhengjinglan on 2018/6/7.
 */

public class PatrolPagerAdapter extends FragmentPagerAdapter {
    //添加fragment的集合
    private String[] pageTitleArr;


    public PatrolPagerAdapter(FragmentManager fm, String[] pageTitleArr) {
        super(fm);
        this.pageTitleArr = pageTitleArr;
    }


    @Override
    public Fragment getItem(int position) {
        //创建fragment并返回
        Fragment fragment=null;
        switch (position){
            case 0:
                fragment = new WaitPatrolFragment();
                break;
            case 1:
                fragment = new AlreadyRepairFragment();
                break;
            case 2:
                fragment = new RepairFragment();
                break;
        }
        return fragment;
    }

    @Override
    public int getCount() {
        return pageTitleArr == null ? 0 : pageTitleArr.length;
    }

    //获取标题
    @Override
    public CharSequence getPageTitle(int position) {
        return pageTitleArr[position];
    }
}
